package com.hzp.net.netty.server;

import com.hzp.net.netty.server.handler.NettyServerInHandlerFilter;
import com.hzp.net.netty.server.handler.NettyServerOutHandlerFilter;
import com.hzp.net.netty.server.handler.ProtocolSelectorHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;
import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler;
import io.netty.handler.stream.ChunkedWriteHandler;

public class ServerChannelInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) {
        socketChannel.pipeline()
                //对http的支持
//                .addLast("http",new HttpServerCodec())
                //对写大数据流的支持
//                .addLast("chunk",new ChunkedWriteHandler())
                //设置单次请求的文件大小上限
//                .addLast("httpObject",new HttpObjectAggregator(1024*1024*10))
                //WebSocket 服务器处理的协议，用于指定给客户端连接访问的路由 : /ws
//                .addLast("ws",new WebSocketServerProtocolHandler("/ws"))
                //自定义的路由
//                .addLast("nin",new NettyServerInHandlerFilter())
//                .addLast("not",new NettyServerOutHandlerFilter());
                .addLast("selector", new ProtocolSelectorHandler());
    }
}
